home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / syscall / sun4.md / userSysCallInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-10  |  2.0 KB  |  59 lines

  1. /*
  2.  * userSysCallInt.h --
  3.  *
  4.  *     Contains macro for stubs for user-level system calls.
  5.  *
  6.  * Copyright 1985, 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * rcs = $Header: /sprite/src/lib/c/syscall/sun4.md/RCS/userSysCallInt.h,v 1.3 89/05/09 23:14:46 rab Exp Locker: rab $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #include "kernel/sysSysCall.h"
  19. #include "kernel/machConst.h"
  20. #ifndef _USERSYSCALLINT
  21. #define _USERSYSCALLINT
  22. /*
  23.  * ----------------------------------------------------------------------------
  24.  *
  25.  * SYS_CALL --
  26.  *
  27.  *      Define a user-level system call.  The call sets up a trap into a 
  28.  *    system-level routine with the appropriate constant passed as
  29.  *     an argument to specify the type of system call.
  30.  *
  31.  *    1) Put constant into global register %g1.  This is what sun OS does,
  32.  *    so the compiler and C library have agreed it's okay to trash g1 when
  33.  *    taking a system call.
  34.  *    2) Execute a software trap instruction.  Arguments to the trap
  35.  *    are left in the output registers, since this is a leaf routine, and
  36.  *    they will become the input registers to the trap window.
  37.  *    3) The return value is left in %o0, since this is a leaf routine,
  38.  *    and it will be found correctly in %o0 by our caller.
  39.  *
  40.  * ----------------------------------------------------------------------------
  41.  */
  42.  
  43. #ifdef __STDC__
  44. #define SYS_CALL(name, constant)    \
  45.     .globl _ ## name; _ ## name:    \
  46.     set    constant, %g1;        \
  47.     ta MACH_SYSCALL_TRAP;         \
  48.     retl;                \
  49.     nop
  50. #else
  51. #define SYS_CALL(name, constant)    \
  52.     .globl _/**/name; _/**/name:    \
  53.     set    constant, %g1;        \
  54.     ta MACH_SYSCALL_TRAP;         \
  55.     retl;                \
  56.     nop
  57. #endif
  58. #endif /* _USERSYSCALLINT */
  59.